package com.sali.asyncollection.service.impl.strategy.method4;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;

/**
 * @description:
 * @author: sali
 * @date: 2024/7/21 下午3:29.
 * @version: 1.0
 */
@Component
@Slf4j
public class AsynMethod04 {


    public void execute(Long userId) throws ExecutionException, InterruptedException {
        CompletableFuture<Boolean> submit1 = CompletableFuture.supplyAsync(() -> {
            log.info("赠送积分成功，用户是：{}", userId);
            return true;
        });
        CompletableFuture<Boolean> submit2 = CompletableFuture.supplyAsync(() -> {
            log.info("发消息订单下单成功，用户是：{}", userId);
            return true;
        });
        System.out.println(submit1.get());
        System.out.println(submit2.get());
    }

}
